<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>收款订单</title>

    <meta name="viewport" id="mobileViewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta name="description" content="！">
    <meta name="Keywords" content="">

    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/reset.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/global.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/iconfont.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/order.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/uc.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/hx/css/dropload.css">
</head>
<body>
<div class="wrapper">
    <header class="header">
        <div class="hl" onclick="javascript:window.history.go(-1);"><span class="iconfont icon-fanhui"></span></div>
        <div class="hc">收款订单</div>
        <div class="hr" onclick="javascript:location.href='${contextPath}/wx/index.htm'"><span class="iconfont icon-zhuye"></span></div>
    </header>
    <div class="space"></div>
    <div class="tabConList">
        <#if page?size &gt;0>
        <div class="tabConItem selected">
            <dl class="orderAll">
                <#list page as order>
                <dd>
                    <div class="clearfix top">
                        <p class="fl">${order.orderno!}</p>
                        <p class="fr cred"><#if order.orderstatus??>${dict.getDicName('order_info_orderStat',order.orderstatus?c)}</#if></p>
                    </div>
                    <div class="clearfix btm">
                        <p class="fl">${order.createtime?string("yyyy-MM-dd HH:mm:ss")}</p>
                        <p class="fr">合计：<span class="cred">￥${order.amount?string("0.00")}</span></p>
                    </div>
                    <div class="clearfix btm">
                        <#if order.orderstatus==0>
                            <a href="" class="btn2 fr">去支付</a>
                            <a href="" class="btn1 fr">取消订单</a>
                        </#if>

                        <#if order.orderstatus==3><a href="" class="btn2 fr">查看详情</a></#if>
                        <#if order.orderstatus==4><a href="" class="btn1 fr">删除订单</a></#if>
                    </div>
                </dd>
                </#list>
            </dl>
        </div>
        <#else>
        <div class="tabConItem" style="display: block;">
            <div class="ac c85">
                <br>
                <img src="${contextPath}/staticwx/hx/images/kongbai.png" alt="" style="width:30%">
                <p>暂无订单</p>
                <!--<p>去看看有哪些想买的</p>-->
            </div>
        </div>
        </#if>
    </div>
</div>
<input type="hidden" name="pageNum" id="pageNum" value="1"/>
<input type="hidden" name="pageSize" id="pageSize" value="${pageSize!1}"/>
<input type="hidden" name="mid" id="mid" value="${mid}"/>
<input type="hidden" name="totalPage" id="totalPage" value="${totalPage!0}"/>
<input type="hidden" name="ot" id="orderType" value="${ordertype!0}"/>
<input type="hidden" name="s" id="orderStatus" value="${orderstatus!0}"/>
<script src="${contextPath}/staticwx/hx/js/jquery-3.0.0.min.js" type="text/javascript"></script>
<script  src="${contextPath}/staticwx/hx/js/fastclick.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/hx/js/dropload.js"></script>
<script>
    $(function(){
        $(".tabList li").click(function(){
            var orderStatus=$(this).data("status");
            if(orderStatus==undefined){
                orderStatus='';
            }
            var ot=$("#orderType").val();
            var mid=$("#mid").val();
            var url='${contextPath}/wx/order/orderList.htm?ot='+ot+"&s="+orderStatus+"&mid="+mid;
            location.href=url;
        });
    });

    $(function () {
        var curPage = $("#pageNum").val();
        var totalPage=$("#totalPage").val();
        // dropload
        var dropload = $('.wrapper').dropload({
            scrollArea: $('.wrapper'),
            domDown: {
                domClass: 'dropload-down',
                domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
                domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                domNoData: '<hr class="dropload-noData"></hr>'
            },
            loadDownFn: function (me) {
                setTimeout(function () {
                    if (curPage==totalPage||totalPage==0) {
                        me.resetload();
                        me.lock();
                        me.noData();
                        me.resetload();
                        return;
                    }
                    curPage++;
                    $("#pageNum").val(curPage);
                    var result = '';
                    $.ajax({
                        url : '${contextPath}/wx/order/orderListData.htm',
                        data : $("#searchForm").serialize(),
                        type : 'post',
                        cache : false,
                        dataType : 'json',
                        success : function(data) {
                            var json = $.parseJSON(data);
                            if (json.isSuccess == true) {
                                var orderList=json.page;
                                var newDate = new Date();
                                $.each(orderList,function(i,order){
                                    newDate.setTime(parseInt(order.createtime));
                                    var osname='';
                                    if(order.orderstatus==0){
                                        osname='待付款';
                                    }else if(order.orderstatus==1){
                                        osname='已支付';
                                    }else if(order.orderstatus==3){
                                        osname='已完成';
                                    }else if(order.orderstatus==4){
                                        osname='已取消';
                                    }
                                    var opList=order.opList;
                                    result+='<dd>';
                                        result+='<div class="clearfix top">';
                                          result+='<p class="fl">'+order.orderno+'</p>';
                                          result+='<p class="fr cred">'+osname+'</p>';
                                        result+='</div>';
                                        result+='<ul class="orderList">';
                                        result+='</ul>';
                                        result+='<div class="clearfix btm">';
                                        result+='<p class="fl">'+newDate.format('yyyy-MM-dd hh:mm:ss')+'</p>';
                                        result+='<p class="fr">合计：<span class="cred">￥'+parseFloat(order.amount).toFixed(2)+'</span></p>';
                                        result+='</div>';
                                        result+='<div class="clearfix btm">';
                                          if(order.orderstatus==0){
                                              result+='<a href="" class="btn2 fr">去支付</a>';
                                              result+='<a href="" class="btn1 fr">取消订单</a>';
                                          }
                                          if(order.orderstatus==3){
                                              result+='<a href="" class="btn2 fr">查看详情</a>';
                                          }
                                          if(order.orderstatus==4){
                                              result+='<a href="" class="btn1 fr">删除订单</a>';
                                          }
                                        result+='</div>';
                                    result+='</dd>';
                                });
                                $('.orderAll').append(result);
                                me.resetload();
                            }else{
                                alert(json.errorMessage);
                            }
                        },
                        error : function() {
                            //alert("异常！");
                        }
                    });
                }, 500);
            }
        });

    });

    //日期格式化
    Date.prototype.format = function(format) {
        var date = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3)
        };
        if (/(y+)/i.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
        }
        for (var k in date) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1
                    ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
            }
        }
        return format;
    }
</script>
</body>
</html>